package ink.tiptop.controller;

import ink.tiptop.persist.domain.entity.ZjfModuleLocalEntity;
import ink.tiptop.dto.req.local.module.*;
import ink.tiptop.common.domain.rsp.Response;
import ink.tiptop.service.ZjfModuleLocalService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import ink.tiptop.utils.JSON;
/**
 * 本地模块结构视图(ZjfModuleLocalEntity)表控制层
 *
 * @author makejava
 * @since 2020-06-21 20:39:55
 */
@Api("本地模块API")
@RestController
@RequestMapping("zjfModuleLocal")
@Slf4j
public class ModuleLocalController {
    /**
     * 服务对象
     */
    @Resource
    private ZjfModuleLocalService zjfModuleLocalService;

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @ApiOperation("单一查询本地模块")
    @GetMapping("selectOne")
    public ZjfModuleLocalEntity selectOne(Integer id) {
        return this.zjfModuleLocalService.queryById(id);
    }

    /**
     * 通过实体类查询列表数据
     *
     * @param request 实例对象
     * @return 单条数据
     */
    @ApiOperation("查询本地模块列表信息")
    @PostMapping("list")
    @ResponseBody
    public Response list(@RequestBody @Valid QueryZjfModuleLocalRequest request) {
        log.info("查询本地模块列表信息,入参:{}", JSON.toJSONString(request));
        return this.zjfModuleLocalService.list(request);
    }
    @ApiOperation("更新本地模块")
    @PostMapping("update")
    @ResponseBody
    public Response update(@RequestBody @Valid UpdateZjfModuleLocalRequest request) {
        log.info("更新本地模块,入参:{}", JSON.toJSONString(request));
        return this.zjfModuleLocalService.update(request);
    }
    @ApiOperation("批量删除本地模块信息")
    @PostMapping("delete")
    @ResponseBody
    public Response delete(@RequestBody @Valid DeleteZjfModuleLocalRequest request) {
        log.info("批量删除本地模块信息,入参:{}", JSON.toJSONString(request));
        return this.zjfModuleLocalService.delete(request);
    }
    /**
     * @param request 主键
     * @return 单条数据
     */
    @ApiOperation("添加本地模块信息")
    @PostMapping("add")
    @ResponseBody
    public Response add(@RequestBody @Valid AddZjfModuleLocalRequest request) {
        log.info("添加本地模块信息,入参:{}", JSON.toJSONString(request));
        return this.zjfModuleLocalService.add(request);
    }

    /**
     * @param request 主键
     * @return 单条数据
     */
    @ApiOperation("扫描本地模块,批量导入")
    @PostMapping("scan")
    @ResponseBody
    public Response scan(@RequestBody @Valid ScanZjfModuleLocalRequest request) {
        log.info("扫描本地模块,批量导入,入参:{}", JSON.toJSONString(request));
        return this.zjfModuleLocalService.scan(request);
    }

}